package Prefecture;

import java.util.*;

public class Work1 {

    public static void main(String[] args) {

        Map<String, List<String>> provincesAndCities = new HashMap<>();

        provincesAndCities.put("河北", Arrays.asList("石家庄","唐山","保定","秦皇岛","邯郸","邢台","沧州"));

        provincesAndCities.put("河南", Arrays.asList("郑州","开封","洛阳","平顶山","新乡","安阳","鹤壁"));

        provincesAndCities.put("浙江", Arrays.asList("杭州","嘉兴","温州","宁波","绍兴","金华","丽水"));

        provincesAndCities.put("云南", Arrays.asList("昆明","曲靖","大理","丽江","昭通","玉溪","保山"));

        provincesAndCities.put("广东", Arrays.asList("广州","湛江","东莞","佛山","汕头","深圳","汕尾"));

        provincesAndCities.put("山西", Arrays.asList("太原","大同","晋城","阳泉","运城","临汾","长治"));

        provincesAndCities.put("四川", Arrays.asList("成都","自贡","攀枝花","泸州","德阳","绵阳","广元"));


        System.out.println("请选择你所在的省份:");

        for (String province : provincesAndCities.keySet()) {

            System.out.println(province);

        }


        Scanner scanner = new Scanner(System.in);

        String selectedProvince = scanner.nextLine();


        while (!provincesAndCities.containsKey(selectedProvince)) {

            System.out.println("没有找到对应的省份，请重新输入！");

            selectedProvince = scanner.nextLine();

        }

        System.out.println(selectedProvince);

        List<String> cities = provincesAndCities.get(selectedProvince);

        System.out.println("请选择你所在的城市:");

        for (String city : cities) {

            System.out.println(city);

        }


        String selectedCity = scanner.nextLine();

        while (!cities.contains(selectedCity)) {

            System.out.println("没有找到对应的城市，请重新输入！");

            selectedCity = scanner.nextLine();
        }

        System.out.println(selectedCity);

        System.out.println("信息登记完毕");


        scanner.close();

    }

}
